package com.heima.controller;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.heima.mapper.TaskMapper;
import com.heima.pojo.TaskDetails;
import com.heima.pojo.dto.TaskDetailsDto;
import com.heima.pojo.vo.TaskDetailsVo;
import com.heima.pojo.vo.TaskVo;
import com.heima.service.ITaskDetailsService;
import com.heima.service.ITaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工单详情，只有补货工单才有 前端控制器
 *
 * @author xjy
 * @since 2024-06-07
 */
@RestController
@RequestMapping("/task-service/taskDetails")
@Api(tags = "工单详情，只有补货工单才有")
public class TaskDetailsController {
    @Autowired
    private ITaskDetailsService taskDetailsService;

    @GetMapping("/{taskId}")
    @ApiOperation("补货工单详情")
    public List<TaskDetailsVo> taskDetails(@PathVariable Long taskId) {
        LambdaQueryWrapper<TaskDetails> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TaskDetails::getTaskId, taskId);
        List<TaskDetails> list = taskDetailsService.list(queryWrapper);
        return BeanUtil.copyToList(list, TaskDetailsVo.class);
    }
}
